home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
FROMUTS
/
UNIXLIB37B
/
src
/
unix
/
c
/
time
< prev
next >
Wrap
Text File
|
1991-10-06
|
919b
|
59 lines
static char sccs_id[] = "@(#) time.c 1.0 "__DATE__" HJR";
/* time.c (c) Copyright 1990 H.Rogers */
#include <time.h>
#include <errno.h>
#include "sys/os.h"
#include "sys/syslib.h"
clock_t clock(void)
{
unsigned int b[2];
unsigned int t1,t2;
os_error *e;
*((char *)b) = 3;
if (e = os_word(0x0e,b))
{
__seterr(e);
return(-1);
}
t1 = (b[0]);
t2 = (b[1] & 0xff);
if (t2 - __time[1]) { errno = ERANGE; return((clock_t)-1); }
return(t1 - __time[0]);
}
time_t time(time_t *t)
{
unsigned int b[2];
unsigned int t1,t2,tc;
os_error *e;
*((char *)b) = 3;
if (e = os_word(0x0e,b))
{
__seterr(e);
return(-1);
}
t1 = (b[0]);
t2 = (b[1] & 0xff);
tc = 0x6e996a00U;
if (t1 < tc) t2--; t1 -= tc;
t2 -= 0x33; /* 00:00:00 Jan. 1 1970 = 0x336e996a00 */
t1 = (t1 / 100) + (t2 * 42949673U); /* 0x100000000 / 100 = 42949672.96 */
t1 -= (t2 / 25); /* compensate for .04 error */
if (t) *t = t1;
return(t1);
}